#ifndef BSP_ADC_H
#define BSP_ADC_H
#include "main.h"
#define ADC_SYNC_UNITS                  (ADC_SYNC_ADC1_ADC2)
#define ADC_SYNC_MD                     (ADC_SYNC_SINGLE_PARALLEL_TRIG)

#define ADC_SYNC_SPL_TIME               (32U)
#define ADC_SYNC_TRIG_DELAY             (0U)
#define ADC_MD                          (ADC_MD_SEQA_CONT)

#define ADC_PERIPH_CLK                  (FCG3_PERIPH_ADC1 | FCG3_PERIPH_ADC2)

#define ADC1_CHX                        (ADC_CH1)
#define ADC1_CHX_PORT                   (GPIO_PORT_A)
#define ADC1_CHX_PIN                    (GPIO_PIN_01)

#define ADC2_CHX                        (ADC_CH1)
#define ADC2_CHX_PORT                   (GPIO_PORT_A)
#define ADC2_CHX_PIN                    (GPIO_PIN_05)

#define ADC3_CHX                        (ADC_CH1)
#define ADC3_CHX_PORT                   (GPIO_PORT_E)
#define ADC3_CHX_PIN                    (GPIO_PIN_03)

/* ADC channel sampling time */
#define ADC_SPL_TIME                    ADC_SYNC_SPL_TIME

#define SAMP_BUFF_MAX_SIZE              (512)
#define VOL_MAX_CHNUM                   (12)
#define CUR_MAX_CHNUM                   VOL_MAX_CHNUM
#define GPIO_DATA_LEN                   VOL_MAX_CHNUM

#define SAMPLE_TRIG_EVT                 EVT_SRC_TMRA_1_OVF

#define ADC_DMA_UNIT                   (CM_DMA1)    
#define ADC1_DMA_CH                     (DMA_CH0)
#define ADC1_DMA_INT_SRC                INT_SRC_DMA1_TC0
#define ADC2_DMA_CH                     (DMA_CH1)
#define ADC2_DMA_INT_SRC                INT_SRC_DMA1_TC1
#define GPIO_DMA_CH                     (DMA_CH2)
//#define GPIO_DMA_INT_SRC                INT_SRC_DMA1_TC2



extern uint16_t  ADC_OutV[2][SAMP_BUFF_MAX_SIZE*VOL_MAX_CHNUM];   /* Sum of measured values */
extern uint16_t  ADC_OutI[2][SAMP_BUFF_MAX_SIZE*CUR_MAX_CHNUM];   /* Sum of measured values */

void bsp_adc_init(void);
void bsp_timera_init(void);
void bsp_dma_init(void);

#endif
